package com.rockcent.service.impl;

import com.rockcent.common.domain.enumclass.Whether;
import com.rockcent.mall.lib.domain.MerchantCouponProducts;
import com.rockcent.mall.lib.domain.UserMerchant;
import com.rockcent.mall.lib.repository.UserMerchantRepository;
import com.rockcent.service.UserMerchantSrv;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Created by zhangjh on 2017/5/31.
 */
@Service
public class UserMerchantSrvImpl implements UserMerchantSrv {

    @Autowired
    private UserMerchantRepository userMerchantRepository;

    @Override
    public List<Long> findUserIdByMerchantIdAndIsSuperAdmin(Long merchantId, Whether isSuperAdmin) {
        List<UserMerchant> result = userMerchantRepository.findByMerchantIdAndIsSuperAdmin(merchantId,isSuperAdmin);
        List<Long> userIds = result.stream().map(UserMerchant::getUserId).collect(Collectors.toList());
        return userIds;
    }
}
